﻿using System.Xml.Schema;
using System.Xml;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using MsgId = System.Int64;
using System.Text.RegularExpressions;
using PNTSystemClass;
using PNTSystemClass.Framework.Console;

namespace PNTSystemClass
{
    interface ICommandRunningTime
    {
        void Exec();
    }

    public struct MessageId
    {
        public const int VarValueIsNotCommand = 0x11;
        public const int ConsoleInputIsNotCommand = 0x12;
    }

    class CommandFormatException : System.Exception
    {
        public CommandFormatException(string msg, MsgId Msg) : base(msg)
        {
            if(Msg == MessageId.VarValueIsNotCommand)
            {
                
            }
            else if (Msg == MessageId.ConsoleInputIsNotCommand)
            {
                System.Console.ForegroundColor = System.ConsoleColor.Red;
                System.Console.WriteLine(msg);
                System.Console.ResetColor();
            }
            Source = "不存在Commands";
        }
    }

    class CommandIsNofoundExpception : CommandFormatException
    { 
        public CommandIsNofoundExpception(MsgId Msg) : base("命令错误：不存在的命令", Msg)
        {

        }
    }
}

namespace PNTSystemClass.Framework.Console
{
    using System;
    public class Vars
    {
        static public List<string> key = new List<string>(2);
        static public List<string> varString = new List<string>(255);
        static public List<string> varVal = new List<string>(255);
        static public System.Text.StringBuilder commands = new StringBuilder("aaa");
        static public List<string> constVarString = new List<string>(255);
        static public List<string> constVarVal = new List<string>(255);
    }
    public class VarGetFunction
    {
        public static string GetVarValue(string name)
        {
            int index = 0;
            foreach(string names in Vars.varString)
            {
                if(names == name)
                {
                    return Vars.varVal[index];
                }
            }
            return "";
        }

        public static string GetConstVarValue(string name)
        {
            int index = 0;
            foreach(string names in Vars.constVarString)
            {
                if(names == name)
                {
                    return Vars.constVarVal[index];
                }
            }
            return "";
        }
    }
    class Program
    {
        static void OutVCC()
        {
            
        }

        static void Main(String[] args)
        {
            Vars.key.Add("write");
            Vars.key.Add("var");
            Vars.key.Add("read");
            Vars.key.Add("help");
            Vars.key.Add("file");
            Vars.key.Add("bin");
            Vars.key.Add("compare");
            Vars.key.Add("if");
            Vars.key.Add("constvar");
            Vars.key.Add("update");
            Vars.key.Add("downloadfile");
            Vars.key.Add("__GLOBALVARS__");
            if (args.Length != 0)
            {
                if (args[0].StartsWith("comp:"))
                {
                    try
                    {
                        System.IO.StreamReader sr = new System.IO.StreamReader(args[0].Replace("comp:", ""));
                        Command cmd = new Command();
                        while (sr.EndOfStream == false)
                        {
                            cmd.Exec(sr.ReadLine(), Vars.key, ref Vars.varString, ref Vars.varVal);
                        }
                        System.Console.ReadKey();
                    }
                    catch (Exception e)
                    {
                        System.Console.ForegroundColor = ConsoleColor.Red;
                        System.Console.WriteLine("内部引发错误：" + e.Message + "\n调用堆栈:" + e.StackTrace + "\n帮助:" + e.HelpLink);
                        System.Console.ResetColor();
                    }
                }
                
            }
            else
            {
                while (Vars.commands.ToString() != "exit()")
                {
                    try
                    {
                        System.Console.Write(">> ");
                        string commands;
                        commands = System.Console.ReadLine();
                        Vars.commands = Vars.commands.Replace(Vars.commands.ToString(), ((commands != "")? commands : "null()"));
                        Command pc = new Command(Vars.commands.ToString());
                        pc.Exec(Vars.commands.ToString(), Vars.key, ref Vars.varString, ref Vars.varVal);

                        System.Console.Write("\n");
                    }
                    catch(Exception e)
                    {
                        if (e.Source == "不存在Commands")
                        {
                            continue;
                        }
                        else
                        {
                            System.Console.ForegroundColor = ConsoleColor.Red;
                            System.Console.WriteLine("内部引发错误：" + e.Message + "\n调用堆栈:" + e.StackTrace + "\n帮助:" + e.HelpLink);
                            System.Console.ResetColor();
                        }
                    }
                }
            }
        }
    }

    public class Command
    {
        private string Commands;
        public Command(string command)
        {
            Commands = command;
        }
        public Command()
        {
            Commands = "";
        }
        public void Exec(string Commands, List<string> Keys, ref List<string> varn, ref List<string> varvu, MsgId Msg = MessageId.ConsoleInputIsNotCommand)
        {/*
            XmlReaderSettings readerSettings = new XmlReaderSettings();

            readerSettings.IgnoreComments = true;
            readerSettings.Schemas.Add(null, "APIXmlElement.xsd");
            readerSettings.ValidationType = readerSettings.ValidationType;
            readerSettings.Schemas = readerSettings.Schemas;
            readerSettings.ValidationEventHandler += new ValidationEventHandler((object sender, ValidationEventArgs e) =>
            {
                ErrorDialog ed = new ErrorDialog("模块配置文件格式错误", "{Error:\"格式错误\",Msg:\"" + e.Message + "\",\n,StackTrace:\"" + e.Exception.StackTrace + "\",\nErrorSourceUri:\"" + e.Exception.SourceUri + "\",\nHResult:\"" + e.Exception.HResult + "\"}");
                ed.Show();
            });
            readerSettings.DtdProcessing = DtdProcessing.Parse;
            XmlReader reader = XmlReader.Create("APIExec.xml", readerSettings);
            reader.Settings.DtdProcessing = DtdProcessing.Parse;*/

            var Text = new System.Text.RegularExpressions.Regex(@"^(((\w)+\()|(((\w)+\.)))").Match(Commands).Value.Replace("(", "").Replace(".","");
            var SystemFun = new Regex(@"__(.+)__");
            bool IsSystemFun = false;
            switch (SystemFun.Match(Commands).Value)
            {
                case "__GLOBALVARNAMES__":
                    __GLOBALVARS__ __GLOBALVARS_ = new __GLOBALVARS__();
                    __GLOBALVARS_.Exec(Commands);
                    IsSystemFun = true;
                    break;
            }
            if (IsSystemFun == false)
            {
                switch (Text)
                {
                    case "":
                        throw new PNTSystemClass.CommandFormatException("语法错误：无法识别的命令类型", Msg);
                        break;
                    default:
                        foreach (string key in Keys)
                        {
                            if (Text == key)
                            {
                                if (key == "write")
                                {
                                    PaintConsole pc = new PaintConsole(Commands);
                                    pc.Exec(varn, varvu, pc.Text, pc.isenter, pc.modes, Msg);
                                    break;
                                }
                                else if (key == "var")
                                {
                                    DefVar vr = new DefVar();
                                    vr.Exec(Commands);
                                }
                                else if (key == "read")
                                {
                                    string inputv = ReadChars.ToInputValue();
                                    System.Console.WriteLine(inputv);
                                }
                                else if (key == "help")
                                {
                                    Help help = new Help();
                                    help.Exec();
                                }
                                else if (key == "file")
                                {
                                }
                                else if (key == "bin")
                                {
                                    Bin bin = new Bin();
                                    bin.Exec(Commands);
                                }
                                else if (key == "compare")
                                {
                                    Compare compare = new Compare();
                                    compare.Exec(Commands);
                                }
                                else if (key == "if")
                                {
                                    If ifs = new If();
                                    ifs.Exec(Commands);
                                }
                                else if (key == "constvar")
                                {
                                    ConstVar cv = new ConstVar();
                                    cv.Exec(Commands);
                                }
                                else if (key == "exec")
                                {
                                    Exec exec = new Exec();
                                    exec.ExeC(Commands);
                                }
                                else if (key == "update")
                                {
                                    System.Diagnostics.Process pros = new System.Diagnostics.Process();
                                    pros.StartInfo.FileName = "Functions\\PVMUpdate.exe";
                                    pros.StartInfo.UseShellExecute = false;
                                    pros.StartInfo.RedirectStandardInput = true;
                                    pros.StartInfo.CreateNoWindow = false;
                                    pros.StartInfo.RedirectStandardOutput = true;
                                    pros.Start();
                                    string Texts = pros.StandardOutput.ReadToEnd();
                                    PaintConsole pc = new PaintConsole("write('" + Texts + "')");
                                    pc.Exec(Vars.varString, Vars.varVal, pc.Text, pc.isenter, pc.modes, 18);


                                }
                                else if (key == "downloadfile")
                                {
                                    DownloadFile dFile = new DownloadFile();
                                    dFile.Exec(Commands);
                                }
                                else if (key == "null")
                                {

                                }
                                else
                                {
                                    throw new CommandIsNofoundExpception(Msg);
                                }
                            }
                        }
                        break;
                }
            }
            else
            {
                return;
            }
        }
    }

    public class Exec
    {
        public Exec() : base()
        {

        }

        public void ExeC(string Commands)
        {
            var re = new Regex(@"\'\w\s\d\W\S\D\'").Match(Commands).Value.Replace("'", "");
            Command command = new Command();
            command.Exec(re, Vars.key, ref Vars.varString, ref Vars.varVal);
        }
    }

    public class Console
    {
        public string HelpText;

        public Console()
        {

        }
        
        public string VarValue(string varn, List<string> varnl, List<string> varvu)
        {
            int i = 0;
            foreach (var strs in varnl)
            {
                if(varn == varnl[i])
                {
                    return varvu[i];
                }
                i++;
            }
            return null;
        }
    }

    public class PaintConsole : Console
    {
        public static string HelpText = "write(<Text>[,<IsEnter>[,<Modes>]]) 语法:\n    Text:'文字'\n" +
            "    IsEnter: 0|1是否换行\n        Modes: fwtae|feawt换行模式:\n" +
            "fwtae: 先输出再换行\n            feawt: 先换行再输出\n";

        private delegate void CmdFunc(string Text, string isenter, string modes, MsgId Msg);

        private List<string> varnl;
        private List<string> varvu;
        public string Text = string.Empty;
        public string Command;
        public string isenter;
        public bool IsEnter;
        private event CmdFunc cFunc;

        private enum Mode
        {
            FirstEnterAgainWriteText = 1,
            FirstWriteTextAgainEnter,
        }
        private Mode mode = new Mode();
        public string modes;

        public PaintConsole(string command)
        {
            cFunc += new CmdFunc(CFunc);
            Command = command;
            Text = new System.Text.RegularExpressions.Regex(@"(\'[\w\s\W\S]+\')|(--\w+--)", System.Text.RegularExpressions.RegexOptions.ECMAScript).Match(command).Value.Replace("'", "");
            isenter = new System.Text.RegularExpressions.Regex(@"(,([01]{0,1}))?").Match(command).Value.Replace(",", "");
            modes = new System.Text.RegularExpressions.Regex(@"(,(\w{0,5}))?").Match(command).Value.Replace(",", "");
        }

        public void Exec(List<string> varnl, List<string> varvu, string Text, string isenter, string modes, MsgId Msg)
        {
            this.varnl = varnl;
            this.varvu = varvu;
            cFunc(Text, isenter, modes, Msg);
        }

        private void If(string Text)
        {
            if (Text.StartsWith("--") == true && Text.EndsWith("--") == true)
            {
                global::System.Console.Write(VarValue(Text, this.varnl, this.varvu));
            }
            else
            {
                global::System.Console.Write(Text);
            }
        }

        private void CFunc(string Text, string isenter, string modes, MsgId Msg)
        {
            if (isenter == "1")
            {
                if (modes == "feawt")
                {
                    System.Console.Write("\n");
                    If(Text);
                }
                else if (modes == "fwtae")
                {
                    If(Text);
                    System.Console.Write("\n");
                }
                else if (modes == "")
                {
                    If(Text);
                    System.Console.Write("\n");
                }
                else
                {
                    throw new CommandFormatException($"语法错误:\"{Command}\"", Msg);
                }
            }
            else if (isenter == "0")
            {
                If(Text);
            }
            else if (isenter == "")
            {
                If(Text);
            }
            else
            {
                throw new CommandFormatException($"语法错误:\"{Command}\"", Msg);
            }
        }

        public static class DeveloperMode
        {
            public static void PaintText(string list_Document, ConsoleColor consoleColor)
            {
                System.Console.ForegroundColor = consoleColor;
                System.Console.WriteLine(list_Document.Replace("[", "").Replace("]", "").Replace("'", ""));
                System.Console.ForegroundColor = ConsoleColor.Gray;
            }

            public static void WriteNullLine()
            {
                PaintText("", ConsoleColor.Gray);
            }
        }
    }

    public class DefVar
    {
        public static string HelpText = "var(<varname>,<varvalue>) 语法:\n    varname: --变量名称--\n    varvalue: [<值>|<命令>]\n";

        List<string> varnamelist = new List<string>(255);
        List<string> varvaluelist = new List<string>(255);
        string thisvarname = "";
        bool IsAgainVarName = false;
        int index = 0;
        public DefVar()
        {
                
        }

        private string CommandIf(string Value)
        {
            switch (Value)
            {
                case "":
                    throw new CommandFormatException("", MessageId.VarValueIsNotCommand);
                    return null;
                case "read()":
                    return ReadBase.ToInputValue();
                default:
                    return Value;
            }
        }

        public void Exec(string Command)
        {
            rename(Command);
            revalue(Command);
        }

        public void rename(string Command)
        {
            System.Text.RegularExpressions.Regex varname = new System.Text.RegularExpressions.Regex(@"--[a-zA-Z0-9-_]+--");
            string varnamev = varname.Match(Command).Value;
            foreach(string names in Vars.varString)
            {
                if(names == varnamev)
                {
                    IsAgainVarName = true;
                    break;
                }
                index++;
            }
            if(IsAgainVarName == true)
            {
                return;
            }
            else
            {
                Vars.varString.Add(varnamev);
            }
        }
        public void revalue(string Command)
        {
            System.Text.RegularExpressions.Regex value = new System.Text.RegularExpressions.Regex(@"\[([a-zA-Z0-9-_]+\])|(\[[a-zA-Z0-9-_]+\(\)\])");
            string varvaluev = value.Match(Command).Value.Replace("[", "").Replace("]", "");
            System.Text.RegularExpressions.Regex command = new System.Text.RegularExpressions.Regex(@"\[\w\(.+\)\]");
            try
            {
                if (IsAgainVarName == true)
                {
                    Vars.varVal[index] = CommandIf(varvaluev);
                }
                else
                {
                    Vars.varVal.Add(CommandIf(varvaluev));
                }
            }
            catch(CommandFormatException)
            {
                Vars.varVal.Add(varvaluev);
            }
        }
    }

    public class ReadBase
    {
        public static string HelpText = "read() 语法:\n    read(): 读取一行文字\n";

        string Value;

        public override string ToString()
        {
            return Value;
        }

        static public string ToInputValue()
        {
            ReadBase rb = new ReadBase();
            rb.Value = System.Console.ReadLine();
            return rb.Value;
        }

        static public bool operator ==(ReadBase @read, ReadBase @reads)
        {
            return ((read.Value == reads.Value) ? true : false);
        }

        static public bool operator !=(ReadBase @read, ReadBase @reads)
        {
            return ((read.Value != reads.Value) ? true : false);
        }

        static public string operator +(ReadBase @read, ReadBase @reads)
        {
            return read.Value + reads.Value;
        }

        public override bool Equals(object obj)
        {
            return ((obj is ReadBase) ? true : false);
        }

        public override int GetHashCode()
        {
            return base.GetHashCode();
        }
    }

    public class ReadChars : ReadBase
    {
        
    }

    public class Bin : Console
    {
        struct ModeId
        {
            public const int Bin = 2;
            public const int Oct = 8;
            public const int Hex = 10;
            public const int Dec = 16;
        }

        public Bin() : base()
        {

        }

        static public int ToInt(string Str)
        {
            if (Str == "2")
            {
                return ModeId.Bin;
            }
            else if (Str == "8")
            {
                return ModeId.Oct;
            }
            else if (Str == "10")
            {
                return ModeId.Hex;
            }
            else if (Str == "16")
            {
                return ModeId.Dec;
            }
            else
            {
                return 10;
            }
        }

        public void Exec(string Command)
        {
            System.Text.RegularExpressions.Regex value = new System.Text.RegularExpressions.Regex(@"\((([\d]+)|(--[\w\d\s\W\D\S]+--))");
            string number = value.Match(Command).Value.Replace("(", "");
            int nb;
            if (number.StartsWith("--")&number.EndsWith("--"))
            {
                try
                {
                    nb = System.Convert.ToInt32(VarValue(number, Vars.varString, Vars.varVal));
                }
                catch
                {
                    nb = 0;
                }
            }
            else
            {
                nb = System.Convert.ToInt32(number);
            }
            System.Text.RegularExpressions.Regex Id = new System.Text.RegularExpressions.Regex(@",[\d]{1,2}");
            System.Console.WriteLine(System.Convert.ToString(nb, toBase:ToInt(Id.Match(Command).Value.Replace(",", ""))));
        }
    }

    public class Compare
    {
        public Compare()
        {

        }

        public bool Exec(string Command, int isIf = 0)
        {
            System.Text.RegularExpressions.Regex values = new System.Text.RegularExpressions.Regex(@"[0-9]+");
            System.Text.RegularExpressions.Regex Symbol = new System.Text.RegularExpressions.Regex(@"\s(==|>|<|!=)\s");
            int[] valay = new int[2] { System.Convert.ToInt32(values.Matches(Command)[0].Value.Replace(" ","").Replace(" ","")), System.Convert.ToInt32(values.Matches(Command)[1].Value) };
            switch(Symbol.Match(Command).Value.Replace(" ", ""))
            {
                case ">":
                    if(isIf == 0)
                    {
                        System.Console.WriteLine((valay[0] > valay[1]) ? "True" : "False");
                        return false;
                    }
                    else
                    {
                        return ((valay[0] > valay[1]) ? true : false);
                    }
                    break;
                case "<":
                    if (isIf == 0)
                    {
                        System.Console.WriteLine((valay[0] < valay[1]) ? "True" : "False");
                        return false;
                    }
                    else
                    {
                        return ((valay[0] < valay[1]) ? true : false);
                    }
                    break;
                case "==":
                    if (isIf == 0)
                    {
                        System.Console.WriteLine((valay[0] == valay[1]) ? "True" : "False");
                        return false;
                    }
                    else
                    {
                        return ((valay[0] == valay[1]) ? true : false);
                    }
                    break;
            }
            return false;
        }
    }

    public class ConstVar : VarGetFunction
    {
        bool IsAgainVarName = false;
        int index = 0;

        public ConstVar()
        { 
        }

        private string CommandIf(string Value)
        {
            switch (Value)
            {
                case "":
                    throw new CommandFormatException("", MessageId.VarValueIsNotCommand);
                    return null;
                case "read()":
                    return ReadBase.ToInputValue();
                default:
                    return ((Value.StartsWith("--") && Value.EndsWith("--")) ? GetVarValue(Value) : ((Value.StartsWith("-") && Value.EndsWith("-")) ? GetConstVarValue(Value) : Value));
            }
        }

        public void Exec(string Command)
        {
            rename(Command);
            revalue(Command);
        }

        public void rename(string Command)
        {
            System.Text.RegularExpressions.Regex varname = new System.Text.RegularExpressions.Regex(@"-[a-zA-Z0-9-_]+-");
            string varnamev = varname.Match(Command).Value;
            foreach (string names in Vars.constVarString)
            {
                if (names == varnamev)
                {
                    IsAgainVarName = true;
                    break;
                }
                index++;
            }
            if (IsAgainVarName == true)
            {
                return;
            }
            else
            {
                Vars.constVarString.Add(varnamev);
            }
        }
        public void revalue(string Command)
        {
            System.Text.RegularExpressions.Regex value = new System.Text.RegularExpressions.Regex(@"\[([a-zA-Z0-9-_]+\])|(\[[a-zA-Z0-9-_]+\(\)\])");
            string varvaluev = value.Match(Command).Value.Replace("[", "").Replace("]", "");
            System.Text.RegularExpressions.Regex command = new System.Text.RegularExpressions.Regex(@"\[\w\(.+\)\]");
            if (IsAgainVarName == true)
            {
                throw new CommandFormatException("由于此变量是常量，您不能修改此值", MessageId.ConsoleInputIsNotCommand);
            }
            else
            {
                try
                {
                    Vars.constVarVal.Add(CommandIf(varvaluev));
                }
                catch(CommandFormatException)
                {
                    Vars.constVarVal.Add(varvaluev);
                }
            }
        }
    }

    public class DownloadFile
    {
        public void Exec(string Command)
        {
            Regex re = new Regex(@"\[(.+)\]");
            string webname = re.Matches(Command)[0].Value;
            string name = re.Matches(Command)[1].Value;
            string mode = re.Matches(Command)[2].Value;
            System.Diagnostics.Process pro = new System.Diagnostics.Process();
            pro.StartInfo.FileName = "Functions\\DownloadWebFile.exe";
            pro.StartInfo.Arguments = $"{webname} {name} {mode}";
            pro.StartInfo.UseShellExecute = false;
            pro.StartInfo.RedirectStandardOutput = true;
            pro.StartInfo.RedirectStandardError = true;
            pro.StartInfo.CreateNoWindow = true;
            pro.StartInfo.WorkingDirectory = System.IO.Directory.GetCurrentDirectory();
            pro.Start();
            string output = pro.StandardOutput.ReadToEnd();
            System.Console.WriteLine(output);
        }

    }

    public class If
    {
        public If()
        {}

        public void Exec(string Command)
        {
            System.Text.RegularExpressions.Regex conditions = new System.Text.RegularExpressions.Regex(@"\scompare\s");
            Regex command = new Regex(@"\scompare\((.+)\)\s");
            if (conditions.Match(Command).Value == "compare")
            {

                Compare compare = new Compare();
                bool istrue = compare.Exec(command.Match(Command).Value, 1);
                if (istrue == true)
                {
                    Command command1 = new Command();
                    foreach (char char1 in command.Match(Command).Value)
                    {
                        string command2 = "";
                        if (char1 == '{')
                        {
                            if (char1 != '}')
                            {
                                command2 = command2 + char1;
                            }
                            else
                            {
                                command1.Exec(command2, Vars.key, ref Vars.varString, ref Vars.varVal);
                                break;
                            }
                        }
                    }
                }
                else
                {
                    return;
                }
            }
        }
    }

    class __GLOBALVARS__
    {
        public __GLOBALVARS__()
        {

        }

        public void Exec(string Command)
        {
            Regex index = new Regex(@"\[\d+\]");
            int __index__ = Convert.ToInt32(index.Match(Command).Value.Replace("[", "").Replace("]", ""));
            System.Console.WriteLine(Vars.varString[__index__]);
        }
    }

    public class Help
    {
        public void Exec()
        {
            System.Console.Write(PaintConsole.HelpText);
            System.Console.Write(DefVar.HelpText);
            System.Console.Write(ReadBase.HelpText);
        }
    }
}

namespace PSystem.Framework.Console.File
{
    class File
    {
        public static string HelpText = "file.Read(<filename>)|Write(<filename>,<text>)|Create(<filename>) 语法:\n    file.Read(<filename>) 语法:\n        filename: 文件名\n   file.Write(<filename,<text>) 语法:\n        filename: 文件名\n        text: '文本'\n    file.Create(<filename>) 语法:\n        filename: 文件名\n";

        public File()
        {

        }

        public void Exec(string c)
        {
            System.Text.RegularExpressions.Regex keyfun = new System.Text.RegularExpressions.Regex(@"file\.(Read)|(Write)|(Create)");
            System.Text.RegularExpressions.Regex path = new System.Text.RegularExpressions.Regex(@"(\'([A-Za-z]:\\)((([\w\d\s\d]+)\.([\w]+))\'|\'(((([\w\d\s]\\)+)([\w\s\d]+\.[\w]))))\'|\'((\w)+\.(\w)+))\'");
            
            if (keyfun.Match(c).Value == "file.Read")
            {
                StreamReader fs = new StreamReader(Directory.GetCurrentDirectory() + "\\" + path.Match(c).Value.Replace("'", ""));
                while (!fs.EndOfStream)
                {
                    System.Console.WriteLine(fs.ReadLine());
                }
                fs.Close();
            }
            else if (keyfun.Match(c).Value == "file.Write")
            {
                StreamWriter ws = new StreamWriter(Directory.GetCurrentDirectory() + "\\" + path.Match(c).Value.Replace("'", ""));
                System.Text.RegularExpressions.Regex text = new System.Text.RegularExpressions.Regex(@"(\'[\w\s\d\W\S\D]+\')");
                ws.Write(text.Match(c).Value);
                ws.Close();
            }
            else if (keyfun.Match(c).Value == "file.Create")
            {
                FileStream fs = new FileStream(Directory.GetCurrentDirectory() + "\\" + path.Match(c).Value.Replace("'", ""), FileMode.CreateNew);
                fs.Close();
            }
        }
    }
}
